﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace Web_cuiki
{
    public partial class WebForm6 : System.Web.UI.Page
    {
        private string sachMoi;

        public string SachMoi
        {
            get { return sachMoi; }
            set { sachMoi = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Membership.GetUser() == null)
            {
                this.Response.Redirect("Login.aspx");
            }
            String username = Membership.GetUser().UserName;
           List<HOA_DON> listHoaDon= HoaDonDAO.laydsHoaDonTheoTenDangNhap(username);
            for (int i = 0; i < listHoaDon.Count; i++)
            {
                SachMoi += @" <div class='clear'/>
<div class='contact_form'>
                <div class='form_subtitle'>Hóa đơn ngày:" + listHoaDon[i].NgayDatHang +
                    @"</div>
                        
                    <div class='form_row'>
                    <label class='contact'><strong>Username:</strong></label>
                    <label class='contact'> " + username + "</label>" +
                        @"</div>  
                    <div class='form_row'>
                    <label class='contact'><strong>Tổng tiền:</strong></label>
                    <label class='contact'> " + listHoaDon[i].TongTien + "</label>" +
                        @"</div> 
                    <div class='form_row'>
                    <label class='contact'><strong>Tình trạng:</strong></label>
                    <label class='contact'> ";
                if (listHoaDon[i].TinhTrang == false)
                {
                    SachMoi += "Chưa thanh toán";
                }
                else
                {
                    SachMoi += "Đã thanh toán";
                }
                SachMoi+=  "</label>" +
                        @"</div> 
                   <div class='form_row'>
                    <label class='contact'><strong>Nhà Vận chuyển:</strong></label>
                    <label class='contact'> " + NhaVanChuyenDAO.TimTenTheoMa(listHoaDon[i].MaNhaVanChuyen.ToString()).TenNhaVanChuyen + "</label>" +
                        @"</div> 
               
                     <table width='400px'>
                            <tr>
                                    <td> <strong>Tên Sản Phẩm</strong> </td>
                                    <td><strong>Số Lượng<strong ></td>
                                    <td><strong>Giá Bán<strong></td>
                            </tr>  ";
                List<CHI_TIET_HOA_DON> listChiTiet = HoaDonDAO.TimDonDatHangTheoMa(listHoaDon[i].MaHoaDon);
                for (int j = 0; j < listChiTiet.Count;j++ )
                {
                    SachMoi += @"   
                             <tr>
                              <td> "+ listChiTiet[j].SAN_PHAM.TenSanPham +
                            @" </td>
                             <td>" + listChiTiet[j].SoLuong+
                            @" </td>
                             <td> " + listChiTiet[j].GiaLucMua+
                            @"</td>
                            </tr>    
                    ";
                }

                    SachMoi+=@"
                     </table>                      

                </div>  
          </div>	
           

";
            }
            
        }
    }
}